select
  't' as transfer_category,
  t.source,
  t.source as source_pair,
  t.from_stop_id,
  t.to_stop_id,
  v1.parent_station as from_stop_idu,
  v2.parent_station as to_stop_idu,
  t.source || '_' || v1.parent_station as from_stop_sidu,
  t.source || '_' || v2.parent_station as to_stop_sidu,
  t.transfer_type,
  t.min_transfer_time,
  6371.0 * acos(
    sin(90.0 - s1.stop_lat * pi() / 180.0) *
    sin(90.0 - s2.stop_lat * pi() / 180.0) *
    cos(
      (s1.stop_lon * pi() / 180.0) -
      (s2.stop_lon * pi() / 180.0)
    ) +
    cos(90.0 - s1.stop_lat * pi() / 180.0) *
    cos(90.0 - s2.stop_lat * pi() / 180.0)
  ) as dist_km
from transfers t
  join _cvstopparent v1 on t.from_stop_id = v1.stop_id and v1.source = t.source
  join stops s1 on v1.stop_id = s1.stop_id and v1.source = s1.source
  join _cvstopparent v2 on t.to_stop_id = v2.stop_id and v2.source = t.source
  join stops s2 on v2.stop_id = s2.stop_id and v2.source = v2.source
